//
//  DownloadRecvData.h
//  mcf
//
//  Created by yuike6 yuike6 on 12-2-8.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

/*
    在使用的时候，使用 DownloadRecvDataMemory || DownloadRecvDataFileSystem 进行数据
    的接收，不能直接使用基类 DownloadRecvData 这里面什么事情都没有做。
 */

#import "YDownloadImageModel.h"

@interface DownloadRecvData : NSObject
{
    NSString * name_;        
    NSString * localCacheDirPath_;
    
    long long needRecvDataLenght_;
    
    BOOL valid_;
    BOOL bCached;
    
    BOOL bCheckRecvDataLenght;
    
    YDownloadImageModel * downloadModel_;
    
    BOOL recvFinished;
    
}
@property (nonatomic, copy) NSString * name;
@property (nonatomic, copy) NSString * localCacheDirPath;

@property (nonatomic, assign) long long needRecvDataLenght;
@property (nonatomic, assign) BOOL valid;

@property (nonatomic, assign) BOOL bCached;
@property (nonatomic, assign) BOOL bCheckRecvDataLenght;

@property (nonatomic, strong) YDownloadImageModel * downloadModel;
@property (nonatomic, assign, getter = isRecvFinished) BOOL recvFinished;


-(void) AppendData : (NSData *) data;

- (void) processRecvAllDataFinish;
- (void) processRecvAllDataFalied;

- (long long)length;

- (NSData *) data;
- (void) clearData;

@end


@interface DownloadRecvDataMemory : DownloadRecvData 
{
    NSMutableData *data_;
}
@property (retain) NSMutableData *recvData;
@end

@interface DownloadRecvDataFileSystem : DownloadRecvData 
{
    NSString * localFullPath_;
    
    NSFileHandle* file_handle_;
    
    BOOL isCraeteByMyself;
    
    NSString * tmpFullPath_;
    
}

@property (nonatomic, copy) NSString * localFullPath;
@property (nonatomic, retain) NSFileHandle * fileHandle;

@property (nonatomic, copy) NSString * tmpFullPath;

@end